﻿using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using IMES.Entity;
using System.Data;

namespace IMES.BLL
{
    /// <summary>
    /// 菜单-仓储处理
    /// </summary>
    public class MenuRep : BaseRepository<Menu>, ITransient
    {
        /// <summary>
        /// 所有菜单列表
        /// </summary>
        /// <returns></returns>
        public List<Menu> GetMenuTree()
        {
            var list =
                Context.Queryable<Menu>().ToTree(it => it.Childs, it => it.ParentNo,0,it=>it.No)
                .Where(x=>!x.IsDeleted)
                .OrderBy(x => x.SortID)
                .ToList();
            return list;
        }
        /// <summary>
        /// 获取所有报表节点
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public DataTable GetReportNodes()
        {
            return Context.Ado.GetDataTable("SELECT `No`,`Name`,Title,ParentNo,Usable,Remark,`Level` FROM samenu WHERE IsDeleted=0 AND isreport=1 AND `level`<4 ");
        }

        /// <summary>
        /// 获取用户有权限的报表列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Menu> GetReportsByUser(long userId)
        {
            throw new NotImplementedException();
        }
    }
}
